package action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import dao.AdminDao;

public class AdminLoginAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private AdminDao adminDao;
    private String adminName;
    private String adminPassword;
    
	public String execute(){
		if(adminDao.doLogin(adminName, adminPassword)){
			HttpServletRequest req=ServletActionContext.getRequest();
			HttpSession session=req.getSession();
			session.setAttribute("admin_username", adminName);
			return "success";
		}else{
			return "input";
		}
		
	}
	public String getAdminName() {
		return adminName;
	}
	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}
	public String getAdminPassword() {
		return adminPassword;
	}
	public void setAdminPassword(String adminPassword) {
		this.adminPassword = adminPassword;
	}

	public AdminDao getAdminDao() {
		return adminDao;
	}
	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}
	
	
}
